{% extends "base.html" %}

{% block head-title %}{{algorithm.algorithm_name}}{% endblock %}

{% block title %}{{algorithm.algorithm_name}}{% endblock %}

{% block content %}
<div style="float: right;">
	<a href="/static/{{algorithm.instance_id}}/{{algorithm.data_source_name}}"
		class="uk-button uk-button-success" target="_blank">数据文件</a>
	<a href="/show_source_code?instance_id={{algorithm.instance_id}}"
		class="uk-button uk-button-primary" target="_blank">源代码</a>
</div>
<h2>数据源</h2>
<table class="uk-table uk-table-striped">
	<caption>记录数:{{algorithm.data_source_size}}</caption>
	<thead>
		<tr>
			<th>序号</th> 
			{% for column in algorithm.data_source.columns %}
			<th>{{ column }}</th> 
			{% endfor %}
		</tr>
	</thead>
	<tbody>
		{% for values in algorithm.data_source.head.values %}
		<tr>
			<td>{{ forloop.counter }}</td>
			{% for value in values%}
			<td>{{ value }}</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</tbody>
</table>
<hr />

<h2>模型</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>项目</th>
			<th>内容</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>输入字段</td>
			<td>{{ algorithm.input_field_names|join:"|" }}</td>
		</tr>
		<tr>
			<td>分类字段</td>
			<td>{{ algorithm.output_field_name }}</td>
		</tr>
		
		{% ifequal algorithm.algorithm_name "KNN近邻法" %}
		<tr>
			<td>K值</td>
			<td>{{ algorithm.k_value }}</td>
		</tr>
		{% endifequal %}
		
		{% ifequal algorithm.algorithm_name "朴素贝叶斯" %}
		<tr>
			<td>模型类型</td>
			<td>{{ algorithm.model_type }}</td>
		</tr>
		{% endifequal %}
		
		{% ifequal algorithm.algorithm_name "决策树" %}
		<tr>
			<td>特征选择标准</td>
			<td>{{ algorithm.criterion }}</td>
		</tr>
		<tr>
			<td>最大深度</td>
			<td>{{ algorithm.max_depth }}</td>
		</tr>
		{% endifequal %}
		
		{% ifequal algorithm.algorithm_name "支持向量机" %}
		<tr>
			<td>核函数</td>
			<td>{{ algorithm.kernel }}</td>
		</tr>
		{% endifequal %}
		
		{% ifequal algorithm.algorithm_name "多层神经网络" %}
		<tr>
			<td>最优化算法</td>
			<td>{{ algorithm.solver }}</td>
		</tr>
		{% endifequal %}
		
		<tr>
			<td>训练样本数</td>
			<td>{{ algorithm.train_inputs|length }}</td>
		</tr>
		<tr>
			<td>测试样本数</td>
			<td>{{ algorithm.test_inputs|length }}</td>
		</tr>
		<tr>
			<td>模型评分(0~1)</td>
			<td>{{ algorithm.score | floatformat:2 }}</td>
		</tr>
	</tbody>
</table>
<hr />

{% ifequal algorithm.algorithm_name "决策树" %}
<h2>决策树</h2>
<div>
	<a href="/static/{{algorithm.instance_id}}/graph.png/" target="_blank" title="点击查看大图">
		<img src="/static/{{algorithm.instance_id}}/graph.png/">
	</a>
</div>
{% endifequal %}

<h2>预测</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>序号</th>
			{% for name in predict_column_names %}
			<th>{{ name }}</th> 
			{% endfor %}
		</tr>
	</thead>
	<tbody>
		{% for values in predict_values %}
		<tr>
			<td>{{ forloop.counter }}</td>
			{% for value in values%}
			<td>{{ value }}</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</tbody>
</table>

{% endblock %}